/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-01 13:50:14
 * @LastEditTime : 2023-06-01 14:09:28
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\TwoRouter\Supervise.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    AnnexButton,
    ModDataButton,
    DelDataButton,
    OpenThrTouter,
    MultipleSelectionOperation,
} from '../Common/options'

export const Supervise = async ({ OptionsEvent, oneData, Permission, actionRef }) => {
    let dataList = {
        hideInSearch: true,
        pageSize: 10,
        params: { superviseUuid: oneData.uuid },
        initialValues: { uuid: oneData.uuid, superviseUuid: oneData.uuid },
        get: API_LIST()['getSuperviseDetail'],
        added: 'posSuperviseDetail',
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            {
                dataIndex: 'uuid',
                title: 'uuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            {
                dataIndex: 'superviseUuid',
                title: 'superviseUuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            { ...commonTableList.tableName, title: '文件名称', width: 300 },
            {
                dataIndex: 'attachmentUuid',
                title: '文件附件',
                valueType: 'upload',
                valueFile: [1, 2, 3, 4, 5],
                fileUrl: 'fileUrl',
                rules: true,
                hideInTable: true,
            },
            {
                dataIndex: 'fileUrl',
                title: '文件附件',
                valueType: 'hidden',
                hideInSearch: true,
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
                width: 400,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, attachment } = record
                    const { fileUrl } = attachment
                    return [
                        fileUrl && <AnnexButton OptionsEvent={OptionsEvent} key="see" url={fileUrl} title="查看附件" />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url="SuperviseDetail"
                            uuid={uuid}
                        />,
                    ]
                },
            },
        ],
    }
    return dataList
}
